﻿using System;
using UnityEngine.Networking;

public class Consumable : Item
{
    public int consumableIncrement = 1;
    public bool destroyOnUse = true;
    public bool increaseOnUseBySelfName;
    public bool useOnPickup = true;

    public override void OnDeserialize(NetworkReader reader, bool initialState)
    {
        base.OnDeserialize(reader, initialState);
    }

    protected override void OnPickup(Character user)
    {
        base.OnPickup(user);
        if (this.useOnPickup)
        {
            this.Use();
        }
    }

    public override bool OnSerialize(NetworkWriter writer, bool forceAll)
    {
        bool flag;
        bool flag2 = base.OnSerialize(writer, forceAll);
        return (flag | flag2);
    }

    protected override void OnUse(Character user)
    {
        base.OnUse(user);
        if (this.increaseOnUseBySelfName)
        {
            int consumableAmount = user.GetConsumableAmount(base.name);
            user.SetConsumableAmount(base.name, consumableAmount + this.consumableIncrement);
        }
        if (this.destroyOnUse)
        {
            base.DestroyItem();
        }
    }

    private void UNetVersion()
    {
    }
}

